"""
封装处理不同解析文件的方法
"""
import json
from openpyxl import load_workbook
def parse_from_json(filepath):
    data = json.load(open(filepath, mode='r', encoding='utf8'))
    testdata = data['test_data']
    return testdata

def parse_from_excel(filepath,sheetname='sheet1'):
    wb = load_workbook(filename=filepath)
    ws = wb[sheetname]
    test_data = []
    for x in range(2, len(tuple(ws.rows)) + 1):
        test_1_data = []
        for y in range(2, len(tuple(ws.columns))+1):
            test_1_data.append(ws.cell(row=x, column=y).value)
        test_data.append(test_1_data)
    return test_data



